package com.gis507.test.csvdouble;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class CsvReducer extends Reducer<IntWritable, Text,IntWritable,Text> {

    int sum = 0;
    private IntWritable outK = new IntWritable();
    @Override
    protected void reduce(IntWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException {

        sum += key.get();

        outK.set(sum);
        for (Text value : values) {
            context.write(outK,value);
        }

    }
}
